/**
 * 
 * purpose: FADE has ease in and ease out phase...
 * @auth: Ning
 * date: 2009-9-16
 * 
 * */
package core.ease
{
	import core.section.Controller;
	
	import flash.display.DisplayObject;
	
	[Event(name="ready_for_ease_in", type="core.ease.EaseFadeEvents")]
    [Event(name="ready_for_ease_out", type="core.ease.EaseFadeEvents")]
    [Event(name="ready_for_display", type="core.ease.EaseFadeEvents")]
	[Event(name="ease_in_over", type="core.ease.EaseFadeEvents")]
	[Event(name="ease_out_over", type="core.ease.EaseFadeEvents")]
	
	
	
	public class EaseFade extends Controller
	{
		//START...
		
		//PROPERTY...
		
		private var _phase:String;
		
		private var _process:Number;
		
		public static const EASE_IN:String = "ease_in_phase";
		
		public static const EASE_OUT:String = "ease_out_phase";
		
		public static const DISPLAY:String = "display_phase";
		
		
		//CONSTRUCTOR...
		public function EaseFade(target:DisplayObject)
		{
			
			super(target);
		
		}
		
		//METHODS...
		
		//get ready for ease in....
		protected function getReadyForEaseIn():void
		{
			
			//NEED TO BE OVERRIDE...
				
			dispatchEvent(new EaseFadeEvents(EaseFadeEvents.READY_FOR_EASE_IN));
			
		}
		
		
		//get ready for ease out...
		protected function getReadyForEaseOut():void
		{
			
			//NEED TO BE OVERRIDE...
						
			dispatchEvent(new EaseFadeEvents(EaseFadeEvents.READY_FOR_EASE_OUT));
			
		}
				
		//get ready for display...
		protected function getReadyForDisplay():void
		{
			
			//NEED TO BE OVERRIDE...
									
			dispatchEvent(new EaseFadeEvents(EaseFadeEvents.READY_FOR_DISPLAY));
									
			
		}
		
		
		//set phase...
		public function set phase(val:String):void
		{
			
			_phase = val;
									
			switch(phase)
			{
				
				case EASE_IN:
				
				getReadyForEaseIn();
				
				break;
				
				case EASE_OUT:
				try{				
					
					getReadyForEaseOut();
				
				}catch(err:Error){};
				
				break;
								
				case DISPLAY:
												
				getReadyForDisplay();
				
				break;
								
			}
			
		}
		
				
		//get phase...
		public function get phase():String
		{
			
			return _phase;
		}		
		
		
		//ease in...
		public function easeIn():void
		{
			
			//need to be override...
			dispatchEvent(new EaseFadeEvents(EaseFadeEvents.EASE_IN_OVER));
			
		}
		
		
		//ease out...
		public function easeOut():void
		{
			
			//need to be override...
			dispatchEvent(new EaseFadeEvents(EaseFadeEvents.EASE_OUT_OVER));
			
		}
		
		
		//display...
		public function display():void
		{
			
			//need to be override...
			
		}
		
		//get download process...
		public function get downloadProcess():Number
		{
			
			return _process;
			
		}
		
		
		//END
	}
}